#ifndef _COMMON_SYSDEF_H_
#define _COMMON_SYSDEF_H_

#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32

#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")

#include <windows.h>
#include <io.h>

#define snprintf _snprintf

#pragma warning(disable:4996)

#define COW_ASSERT(x) if(!(x)) { LOG_NOTICE(GET_SYS_LOG(), "ASSERT failed->%s", #x); __asm int 3 }

#else

#include <unistd.h> 
#include <errno.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/timeb.h>
#include <netdb.h>
#include <fcntl.h> 
#include <stdarg.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <pthread.h>

#define stricmp  strcasecmp
#define strnicmp strncasecmp

#define COW_ASSERT(x) if(!(x)) { LOG_NOTICE(GET_SYS_LOG(), "ASSERT failed->%s", #x); }

#endif

typedef unsigned char      uchar;
typedef unsigned short     ushort;
typedef unsigned int       uint;
typedef long long          int64;
typedef unsigned long long uint64;

#define DEL_SINGLE(p)   if(NULL != (p)) { delete (p); (p) = NULL; }
#define DEL_ARRAY(p)    if(NULL != (p)) { delete[] (p); (p) = NULL; }

int exe_exit(const char* desc);

int sys_rand();

int get_cpu_count();

void sleep_s(int sec);

void sleep_ms(int msec);

uint get_tick_count();

char* get_cur_time(char* outbuf, int outlen);

int arg_desc(char* outbuf, int outlen, char* msg, ...);

#endif //_COMMON_SYSDEF_H_
